package com.haha.Common;
//import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.annotation.JSONField;
import lombok.*;

import java.util.HashMap;
import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Collectors;

@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class VideoFilter {
    @JSONField(name = "scale", ordinal = 1)
    public String scale;
    @JSONField(name = "colorkey", ordinal = 2)
    public String colorkey;
    @JSONField(name = "boxblur", ordinal = 3)
    public String boxblur;
    @JSONField(name = "hue", ordinal = 4)
    public String hue;
    @JSONField(name = "eq", ordinal = 5)
    public String eq;
    @JSONField(name = "colorchannelmixer", ordinal = 6)
    public String colorchannelmixer;
    @JSONField(name = "volume", ordinal = 7)
    public String volume;
    @JSONField(name = "amerge", ordinal = 8)
    public String amerge;
    @JSONField(name = "overlay", ordinal = 9)
    public String overlay;

    private Map<String, String> dictionary = new HashMap<>();
    public String toString(){
        JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(this));
        System.out.println(jsonObject);
        return  jsonObject.entrySet().stream()
                .filter(o -> o.getValue() != null)
                .map(o -> geneFunction.apply(o.getKey(), o.getValue().toString()))
                .collect(Collectors.joining(";"));
    }

    BiFunction<String, String, String> geneFunction = (key, value) -> {
        String begingStr = "[0:v]";
        dictionary.put(key, value);
//        if (key == "overlay")

        return begingStr;
    };
}
